﻿using System.Reflection;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace ETask.Api.Data
{
    public class UserJsonConverter : JsonConverter<int>
    {
        public override int Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
        {
            return reader.GetInt32();
        }

        public override void Write(Utf8JsonWriter writer, int value, JsonSerializerOptions options)
        {
            writer.WriteNumberValue(value);
            if (value == 0)
            {
                writer.WritePropertyName("CreateByName");
                writer.WriteStringValue("无用户");
            }

        }
    }
}
